<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            background-color: #09a0e6;
            background-size: cover;
            background-position: center;
            font-family: Arial, sans-serif;
        }
        
        .login-container {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }
        
        .login-box {
            padding: 40px;
            background-color: rgba(255, 255, 255, 0.8);
            border-radius: 10px;
            backdrop-filter: blur(100px);
            box-shadow: 0 0 25px rgba(0, 0, 0, 0.2);
        }
        
        .login-box input[type="text"],
        .login-box input[type="password"] {
            width: 100%;
            padding: 10px;
            margin-bottom: 20px;
            border: none;
            border-radius: 5px;
        }
        
        .login-box input[type="submit"] {
            width: 100%;
            padding: 10px;
            background-color: #09a0e6;
            color: #fff;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        
        
        .login-box input[type="submit"]:hover {
            background-color: #0773a5;
        }
    </style>
</head>
<body>
    <div class="login-container">
        <div class="login-box">
            <h2>登录</h2>
            <h3>欢迎使用 博客自助登陆系统</h3>
            <form onsubmit="return validate()">
                <input type="text" placeholder="用户名称" id="username" required>
                <input type="password" placeholder="用户密码" id="password" required>
                <input type="checkbox" id="remember" name="remember">
                <label for="remember">记住登录信息</label>
                <input type="submit" value="Login">
            </form>
        </div>
    </div>
    <script>
        function validate() {
            var username = document.getElementById("username").value;
            var password = document.getElementById("password").value;
            if (username === "root" && password === "Admin123456"){
                if (document.getElementById("remember").checked) {
                localStorage.setItem("isLogin", true);
                localStorage.setItem("username", username);
                } else {
                    sessionStorage.setItem("isLogin", true);
                    sessionStorage.setItem("username", username);
                }
                window.location.href = "index.html"; // 登录成功后跳转到index.html页面
                return false; // 阻止表单的提交
            }
            else if (username === "admin" && password === "Admin123456") {
                if (document.getElementById("remember").checked) {
                localStorage.setItem("isLogin", true);
                localStorage.setItem("username", username);
                } else {
                    sessionStorage.setItem("isLogin", true);
                    sessionStorage.setItem("username", username);
                }
                window.location.href = "index.html"; // 登录成功后跳转到index.html页面
                
                return false; // 阻止表单的提交
            } 
            else {
                alert("Username or password is wrong!");
                return false; // 登录失败，阻止表单的提交
            }
        }
    </script>
</body>
</html>
